package com.asp.alumnisystem.base;


import java.io.Serializable;

/**
 * BaseBean
 */
public class BaseBean<T> implements Serializable {

    /**
     * 请求是否成功
     */
    public boolean success;

    /**
     * 错误码
     */
    public int errorCode = 1;

    /**
     * 错误描述
     */
    public String error = "";

    /**
     * 返回数据
     */
    public T data;


    public static <T> BaseBean<T> requestSuccess(T t){
        BaseBean<T> baseBean = new BaseBean<>();
        baseBean.success = true;
        baseBean.data = t;
        return baseBean;
    }

    public static <T> BaseBean<T> requestFail(String error){
        BaseBean<T> baseBean = new BaseBean<>();
        baseBean.success = false;
        baseBean.error = error;
        return baseBean;
    }

    public static <T> BaseBean<T> requestFail(int errorCode, String error){
        BaseBean<T> baseBean = new BaseBean<>();
        baseBean.success = false;
        baseBean.errorCode = errorCode;
        baseBean.error = error;
        return baseBean;
    }



}
